﻿using LibraryManagement.Custom_Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LibraryManagement.Help
{
    public partial class Feedback : libForm
    {
        private LibManagementEntities context;
        private SecAccountDetail OSecAccount;
        public Feedback()
        {
            InitializeComponent();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnSend_Click(object sender, EventArgs e)
        {
            try
            {
                context = new LibManagementEntities();
                OSecAccount = context.SecAccountDetails.Single(x => x.AccountId == clsStatics.currentUserId);
                var name = OSecAccount.FirstName + " " + OSecAccount.LastName;
                var msgBody = name + "\n" + rtbFeedback.Text;
                MailMessage mail = new MailMessage("mz.testingid@gmail.com", "brutaltemper52@gmail.com", "Feedback", msgBody);
                SmtpClient client = new SmtpClient("smtp.gmail.com");

                client.Port = 587;
                client.Credentials = new NetworkCredential("mz.testingid@gmail.com", "murtaza123");
                client.EnableSsl = true;

                client.Send(mail);
                this.Close();
            }
            catch (Exception ex)
            {
                throw;
            }
        }
    }
}
